package com.project.finance.mobile.bill.service.impl;

import com.project.finance.common.mapper.TbBillMapper;
import com.project.finance.common.po.TbBill;
import com.project.finance.mobile.bill.service.BillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class BillServiceImpl implements BillService {
    @Autowired
    private TbBillMapper tbBillMapper;
//记账
    @Override
    public int insert(TbBill tbBill) {
        int insert = tbBillMapper.insert(tbBill);
        return insert;
    }


    //查询账单
    @Override
    public List<TbBill> listBill(int userId) {
        //封装查询条件
        Example example = new Example(TbBill.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("billUserId", userId);
        List<TbBill> tbBills = tbBillMapper.selectByExample(example);

        return tbBills;
    }

    @Override
    public Integer selectIncome(Integer userId) {
        return tbBillMapper.selectIncome(userId) ;
    }

    @Override
    public Integer selectExpend(Integer userId) {
        return tbBillMapper.selectExpend(userId);
    }

}
